{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "440d361e-f41e-494a-98a3-aa87cf0087af",
   "metadata": {
    "ExecuteTime": {
     "start_time": "2023-12-18T21:17:47.057492Z",
     "end_time": "2023-12-18T21:17:47.375190Z"
    }
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "56c9c6a0-5ed8-4708-b96f-19ea7f50f5b9",
   "metadata": {
    "ExecuteTime": {
     "start_time": "2023-12-18T21:17:47.379866Z",
     "end_time": "2023-12-18T21:17:47.404536Z"
    }
   },
   "outputs": [],
   "source": [
    "# 赌神的牌\n",
    "x = pd.DataFrame({'赌神': ['♣3', '♦2', '♠2', '♣2', '♣10']})\n",
    "# 对手的牌\n",
    "y = pd.DataFrame({'对手': ['♠A', '♥A', '♥K', '♥Q', '♥J']})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "outputs": [
    {
     "data": {
      "text/plain": "    赌神  对手\n0   ♣3  ♠A\n1   ♦2  ♥A\n2   ♠2  ♥K\n3   ♣2  ♥Q\n4  ♣10  ♥J",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>赌神</th>\n      <th>对手</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>♣3</td>\n      <td>♠A</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>♦2</td>\n      <td>♥A</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>♠2</td>\n      <td>♥K</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>♣2</td>\n      <td>♥Q</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>♣10</td>\n      <td>♥J</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 把赌神和对手的牌合并在一起显示\n",
    "pd.concat([x, y], axis=1)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "start_time": "2023-12-18T21:19:09.210798Z",
     "end_time": "2023-12-18T21:19:09.233869Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\58248\\AppData\\Local\\Temp\\ipykernel_14876\\1586883652.py:2: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n",
      "  x.loc[0][0], y.loc[0][0] = y.loc[0][0], x.loc[0][0]\n",
      "C:\\Users\\58248\\AppData\\Local\\Temp\\ipykernel_14876\\1586883652.py:2: FutureWarning: Series.__setitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To set a value by position, use `ser.iloc[pos] = value`\n",
      "  x.loc[0][0], y.loc[0][0] = y.loc[0][0], x.loc[0][0]\n"
     ]
    },
    {
     "data": {
      "text/plain": "    赌神  对手\n0   ♠A  ♣3\n1   ♦2  ♥A\n2   ♠2  ♥K\n3   ♣2  ♥Q\n4  ♣10  ♥J",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>赌神</th>\n      <th>对手</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>♠A</td>\n      <td>♣3</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>♦2</td>\n      <td>♥A</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>♠2</td>\n      <td>♥K</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>♣2</td>\n      <td>♥Q</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>♣10</td>\n      <td>♥J</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 交换赌神和对手的底牌\n",
    "x.loc[0][0], y.loc[0][0] = y.loc[0][0], x.loc[0][0]\n",
    "pd.concat([x, y], axis=1)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "start_time": "2023-12-18T21:21:00.606278Z",
     "end_time": "2023-12-18T21:21:00.622111Z"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
